//
//  BaseModel.m
//  中关村在线
//
//  Created by hy on 16/1/14.
//  Copyright © 2016年 hongyu. All rights reserved.
//

#import "BaseModel.h"

@implementation BaseModel

- (instancetype)initWithDic:(NSDictionary *)dic {
    self = [super init];
    if (self) {
        [self setValuesForKeysWithDictionary:dic];
    }
    return self;
}

+ (instancetype)modelWithDic:(NSDictionary *)dic {
    return [[[[self class] alloc] initWithDic:dic] autorelease];
}

+ (NSMutableArray *)modelWithArray:(NSArray *)array {
    NSMutableArray *arr = [NSMutableArray array];
    for (NSDictionary *dic in array) {
        id model = [[self class] modelWithDic:dic];
        [arr addObject:model];
    }
    return arr;
}
- (void)setValue:(id)value forUndefinedKey:(NSString *)key {
    
}
- (id)valueForUndefinedKey:(NSString *)key {
    return nil;
}
@end
